package com.example.customview

import android.animation.ObjectAnimator
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.animation.AnimationUtils
import android.widget.Toast

class MainActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        val customView = findViewById<CustomView>(R.id.custom_view)
        //使用属性动画使view滑动
//        ObjectAnimator.ofFloat(customView, "translationX", 0.toFloat(), 300.toFloat())
//            .setDuration(1000).start()
        //使用View动画使view滑动
//      customView.animation = AnimationUtils.loadAnimation(this, R.anim.translate)

//        customView.smoothScrollTo(-400, 0)
        val invalidTextView  = findViewById<InvalidTextView>(R.id.invalid_text)
        invalidTextView.setOnLongClickListener {
            Toast.makeText(this, invalidTextView.text, Toast.LENGTH_SHORT).show()
            return@setOnLongClickListener true
        }
    }
}
